define(
    'stopWatch',
    [
        'avalon',
        'text!../../package/StopWatch/stopWatch.html',
        'css!../../package/StopWatch/stopWatch.css'
    ],
    function(avalon,html,css){
        var swvm = avalon.define({
            $id:'stopWatch',
            mm:0,
            ss:0,
            ms:0,
            jcArr:[],   //每一次计次数据
            addArr:[],  //数据增长
            beforeJc:0,
            startFlag:false,
            pauseFlag:false,
            timer:0,
            ready:function(){
                index.content = html;
            },
            update:function(){
                if(swvm.ms != 9){
                    swvm.ms ++;
                }else{
                    swvm.ms = 0;
                    if(swvm.ss != 59){
                        swvm.ss ++;
                    }else{
                        swvm.ss = 0;
                        swvm.mm ++;
                    }
                }
            },
            start:function(){
                swvm.startFlag = true;
                swvm.timer = setInterval(function(){
                    swvm.update();
                },100);
            },
            restart:function(){     //重新初始化
                swvm.pauseFlag = false;
                swvm.timer = setInterval(function(){
                    swvm.update();
                },100);

            },
            pause:function(){
                swvm.pauseFlag = true;
                clearInterval(swvm.timer);
            },
            jici:function(){
                swvm.jcArr.unshift(swvm.mm + ":" + swvm.ss + ":" + swvm.ms);
                //swvm.addArr.push();
            },
            refresh:function(){
                swvm.startFlag = false;
                swvm.pauseFlag = false;
                swvm.jcArr = [];
                swvm.addArr = [];
                swvm.mm = 0;
                swvm.ss = 0;
                swvm.ms = 0;
                swvm.beforeJc = 0;
                clearInterval(swvm.timer);
            }
        });
        window[swvm.$id] = swvm;
        avalon.scan();
    });